package com.louis.affair.service.impl;

import com.louis.affair.service.BookService;
import com.louis.affair.service.CheckoutService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author XRY
 * @date 2023年06月28日14:00
 */
@Service
public class CheckoutServiceImpl implements CheckoutService {
    @Autowired
    private BookService bookService;
    /**
     * 顾客买多本书
     * @param bookIds
     * @param userId
     */
    @Transactional
    @Override
    public void checkout(Integer[] bookIds, Integer userId) {
        for(Integer bookId:bookIds){
            //调用业务逻辑层的方法
            bookService.buyBook(bookId, userId);
        }
    }
}
